require("Thunder/BossMove");
BulletMove =class("BulletMove");
-- BulletMove={};
-- local this=BulletMove;
-- local firePos;
-- local transform;

-- local lateTime=0;

-- function BulletMove.New(prefab)
--     transform=prefab;
--     firePos=transform:Find("firePos");
--     local luaTrigger = transform.gameObject:AddComponent(typeof(LuaRigidTrigger));
--     luaTrigger:AddHandler(this.OnTriggerEnter2D);

--     UpdateBeat:Add(this.Update);
    
-- end
-- function BulletMove.Update()
 
-- end
-- function BulletMove.fire()
--     resMgr:LoadPrefab("Player",{'Bullet'},this.OnLoadPrefab);
-- end
-- function BulletMove.OnLoadPrefab(Prefab)
--     gameObject=newObject(Prefab[0]);
--     local go=gameObject.transform;
--     go.gameObject:AddComponent(typeof(Bullet));
--     go.position=firePos.position;
--     gameObject.Destroy(go.gameObject,2);
-- end
-- function BulletMove.OnTriggerEnter2D(collider)
    
--     log("击中");
    
-- end


function BulletMove:ctor(firePoint,speed)
    self.gameObject=newObject(ThunderManager.prefabs[2]);
    
    self.transform = self.gameObject.transform;

    self.transform.position=firePoint.position;
    self.transform.rotation=firePoint.rotation;

    self.rigid = self.gameObject:GetComponent('Rigidbody2D');
    self.rigid.velocity = firePoint.up*speed;
    
    local luaTrigger = self.gameObject:AddComponent(typeof(LuaRigidTrigger));
    luaTrigger:AddHandler(self.OnTriggerEnter2D,self);
    
end

function BulletMove:OnTriggerEnter2D(collider)
    if(collider.tag=="Enemy")then
        destroy(self.gameObject);
        
    end
    -- if(collider.tag=="Boss")then
    --     UpdateBeat:Remove(self.BossMove.Update);
    --     destroy(collider.gameObject);
    -- end
    
end